package scr.springbootcaffeineredis;

import jakarta.annotation.Resource;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RestController

public class RedisController {
    @Resource
    private CacheFrontendContext cacheFrontendContext;
    @Resource
    private StringRedisTemplate stringRedisTemplate;

    @GetMapping("/get")
    public String get(String key) {
        String value = cacheFrontendContext.getCacheFrontend().get(key).toString();

        return value;
    }


    @GetMapping("/set")
    public String set( String key) {
        String value = UUID.randomUUID().toString();
        stringRedisTemplate.opsForValue().set(key, value);
        return "success:"+value;
    }


}
